package com.cheetah.rest;


import com.cheetah.builder.Result;
import com.cheetah.builder.ResultBuilder;
import com.cheetah.dto.UserDTO;
import com.cheetah.service.UserService;
import com.cheetah.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 人员表 前端控制器
 * </p>
 *
 * @author chrishoo
 * @since 2020-07-24
 */
@RestController
@RequestMapping("/user")
public class UserRest {

    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public Result<UserDTO> addUser(UserVO userVO){
        return ResultBuilder.builder().success(userService.save(userVO));
    }

    @PostMapping("/update")
    public Result<UserDTO> updateUser(UserVO userVO){
        return ResultBuilder.builder().success(userService.update(userVO));
    }

    @PostMapping("/get_users")
    public Result<List<UserDTO>> getUsers(@RequestParam String ids){
        return ResultBuilder.builder().success(userService.findUserByIds(ids));
    }
}

